<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录界面</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(45deg, #6ac1c5, #bda5ff);
        }

        .login-container {
            background: rgba(255, 255, 255, 0.95);
            padding: 2rem;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
        }

        .login-title {
            text-align: center;
            color: #333;
            margin-bottom: 2rem;
            font-size: 1.8rem;
        }

        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: #666;
        }

        .form-group input {
            width: 100%;
            padding: 0.8rem;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 1rem;
            transition: border-color 0.3s ease;
        }

        .form-group input:focus {
            outline: none;
            border-color: #6ac1c5;
        }

        .login-btn {
            width: 100%;
            padding: 0.8rem;
            background: linear-gradient(45deg, #6ac1c5, #bda5ff);
            border: none;
            border-radius: 5px;
            color: white;
            font-size: 1rem;
            cursor: pointer;
            transition: transform 0.3s ease;
        }

        .login-btn:hover {
            transform: translateY(-2px);
        }

        .forgot-password {
            text-align: center;
            margin-top: 1rem;
        }

        .forgot-password a {
            color: #6ac1c5;
            text-decoration: none;
            font-size: 0.9rem;
        }

        .forgot-password a:hover {
            text-decoration: underline;
        }
        .action-btn {
            margin-left: 10px;
            padding: 0.5rem 1.5rem; /* Increased horizontal padding */
            background: #6ac1c5;
            border: none;
            border-radius: 5px;
            color: white;
            font-size: 0.9rem;
            cursor: pointer;
            transition: background 0.3s ease;
            min-width: 80px; /* Set a minimum width */
        }

        .action-btn:hover {
            background: #5aa3a0;
        }
    </style>
</head>
<body>
<div class="login-container">
    <h2 class="login-title">欢迎注册</h2>
    <form action="/getregister" method="post">
        <div class="form-group">
            <label for="username">注册的用户名：</label>
                <input type="text" id="username" name="username" placeholder="请输入要注册的用户名" required>
        </div>
        <div class="form-group">
            <label for="password">注册的密码：</label>
            <input type="password" id="password" name="password" placeholder="请输入要注册的密码" required>
        </div>

        <div class="form-group">
            <label for="email">注册的邮箱：</label>
            <div style="display: flex; align-items: center;">
                <input type="email" id="email" name="email" placeholder="请输入要注册的邮箱" required>
                <button type="button" class="action-btn"  style="background-color:#f5f5f5;color:black;"  onclick="sendVerification1(this)">发送验证码</button>
            </div>
        </div>


        <div class="form-group">
            <div class="verification-code">
                <input type="text" name="email1" placeholder="请输入邮箱验证码">
                </div>
        </div>
        <input type="submit" class="login-btn" value="注册">
<%--        <button type="submit" class="login-btn" onclick="register()">注册</button>--%>
    </form>
</div>

<script>
    var msg = "${msg}";
    if (msg != null&&  msg != '') {
        alert(msg);
    }
</script>
<script src="static/jq/jquery-3.3.1.js"></script>
<script>
    // function register(){
    //     location.href = "index.jsp"
    // }

<%--    function sendVerification(button) {--%>
<%--        let phone = $('#phone').val();--%>
<%--        console.log(phone);--%>
<%--        if(phone != ""){--%>
<%--// Disable the button and start the countdown--%>
<%--            button.disabled = true;--%>
<%--            let countdown = 60;--%>
<%--            button.textContent = `${countdown}秒`;--%>

<%--            const interval = setInterval(() => {--%>
<%--                countdown--;--%>
<%--                button.textContent = `${countdown}秒`;--%>

<%--                if (countdown <= 0) {--%>
<%--                    clearInterval(interval);--%>
<%--                    button.disabled = false;--%>
<%--                    button.textContent = '发送验证码';--%>
<%--                }--%>
<%--            }, 1000);--%>

<%--            // Simulate sending verification code--%>
<%--            alert(`验证码已发送到您的手机！！`);--%>
<%--            --%>
<%--        }else {--%>
<%--            alert(`手机号不能为空！！`);--%>
<%--        }--%>
<%--    }--%>

    function sendVerification1(button) {
        let email = $('#email').val();
        console.log(email);
        if(email != ""){
            // Disable the button and start the countdown
            button.disabled = true;
            let countdown = 60;
            button.innerHTML = countdown+"秒";


            const interval = setInterval(() => {
                countdown--;
                button.innerHTML = countdown+"秒";


                if (countdown <= 0) {
                    clearInterval(interval);
                    button.disabled = false;
                    button.textContent = '发送验证码';
                }
            }, 1000);

            // Simulate sending verification code
            alert(`验证码已发送到您的邮箱！！`);
            $.ajax({
                        url:"/getemail",
                        data:{email:email},
                        dataType:"json",
                        success:function (data){
                            $("#code").test("已发送")
                        }
                    })
        }else {
            alert(`邮箱不能为空！！`);
        }
    }
</script>

</body>
</html>